package ui;

import java.awt.Container;
import java.awt.Toolkit;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JProgressBar;

import core.Phrox;

public class IconLoader extends JFrame{
	
	
	protected Container pane = null;
	protected JLabel label;
	
	public IconLoader() {
		this("");
	}
	public IconLoader(String iconPath) {
		setResizable(false);
		
		setTitle(Phrox.name+" "+Phrox.version+" - loading...");
		ImageIcon i = new ImageIcon(core.Phrox.rootDir+Gui.thumbNail);
		setIconImage(i.getImage());
		setSize(300,215);
		
		pane = new Container();
		pane = getContentPane();
		pane.setLayout(null);
		
		
		iconPath = iconPath.replace("\\", "/");
		System.out.println("ICON:"+iconPath);
		ImageIcon icon = new ImageIcon(iconPath);
		
		label = new JLabel(icon);
		
		//label.setSize(getWidth()-20, getHeight()-30);
		label.setBounds(0, 0, getWidth()-20, getHeight()-60);
		
		
		pane.add(label);
		
		JProgressBar pBar = new JProgressBar();
		pane.add(pBar);
		pBar.setValue(100);
		pBar.setBounds(5, 155, getWidth()-20,20);
		pBar.setIndeterminate(true);
		
		
		//label.setSize(getWidth()-20, getHeight()-30);
		this.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width-getWidth())/2, (Toolkit.getDefaultToolkit().getScreenSize().height-getHeight())/2);

		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		setVisible(true);
	}
	
		
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new IconLoader(Phrox.rootDir+"/res/PhroxMascotSmall.JPG");
		//new IconLoader(f.getAbsolutePath()+"/res/dp_1.JPG");
	}
	
}
